﻿namespace Vampirewal.BlogCore.TestWebApi;

public class TestPage : PageBase
{
    public override bool IsCache => true;
    public override string Title => "测试菜单";
    public override string MenuGroup => "分组1";

    public override int MenuGroupSort => 1;
    public override int Sort => 9;

    public override List<Tag> Tags => new List<Tag>()
    {
        App.CreateTag("测试标签1", TagType.Primary),
        App.CreateTag("测试标签2", TagType.Success),
        App.CreateTag("测试标签3", TagType.Danger),
    };

    public override List<PartContainer> PartContainers => new List<PartContainer>()
    {
        App.CreatePartContainer("测试标题1",(child) =>
        {
            App.CreateTip("测试tip", TipType.Tip,child1 =>
            {
                child1.Add(App.CreateText("    haha", TextType.Default, TextSizeType.Large));
                child1.Add(App.CreateText("haha2", TextType.Primary, TextSizeType.Small));
            }).AddToChildren(child);
        }),

        App.CreatePartContainer("测试标题2",(child) =>
        {
            App.CreateTip("测试warning", TipType.Success, child1 =>
            {
                child1.Add(App.CreateText("haha2", TextType.Primary, TextSizeType.Small));
            }).AddToChildren(child);

            App.CreateCollapse(items =>
            {
                items.Add(App.CreateCollapseItem( "代码", () =>
                {
                    return App.CreateCode(() =>
                    {
                        return $$$"""

                            public class Test
                            {
                                //注释
                                public string Name { get; set; }
                                public int Age { get; set; }
                            }

                        """;
                    });
                }));
            }).AddToChildren(child);

            //App.CreateCode(() =>
            //{
            //    return $$$"""

            //        public class Test
            //        {
            //            //注释
            //            public string Name { get; set; }
            //            public int Age { get; set; }
            //        }

            //    """;
            //}).AddToChildren(child);
        }),

        App.CreatePartContainer("测试标题3", child =>
        {
            App.CreateButtonGroup(bg =>
            {
                var btn= App.CreateButton("按钮1", ButtonType.Default);
                btn.SetClick("TestClick",$$$"""

                    Field1:'haha',
                    Field2:1

                    """);

                bg.Add(btn);
                bg.Add(App.CreateButton("按钮2", ButtonType.Danger));
            }).AddToChildren(child);
        }),

        App.CreatePartContainer("表单", child =>
        {
            

            App.CreateForm<TestFormModel>().AddToChildren(child);
        }),

        App.CreatePartContainer("表格控件", child =>
        {
            List<TestTable> list=new List<TestTable>()
            {
                new TestTable()
                {
                    Name="Test1",
                    Age=1,
                    Address="成都"
                },
                new TestTable()
                {
                    Name="Test2",
                    Age=2,
                    Address="北京"
                }
            };

            App.CreateTable<TestTable>(list).AddToChildren(child);
        }),

        App.CreatePartContainer("图片", child =>
        {
            //App.CreateImage(true,"/assets/Vampirewal-Logo.png").AddToChildren(child);
            App.CreateImage(true,"/assets/clientInfoManager.png","style=\" max-width: 100%; height: auto;  \"").AddToChildren(child);
            App.CreateImage(false,"https://fuss10.elemecdn.com/a/3f/3302e58f9a181d2509f3dc0fa68b0jpeg.jpeg").AddToChildren(child);
        }),

        App.CreatePartContainer("时间轴控件", child =>
        {
            App.CreateTimeLine(300, items =>
            {
                items.Add(new TimeLineItem()
                {
                    Timestamp="2024-07-25",
                    PlacementType= TimeLinePlacementTypeEnum.Top,
                    Content="测试时间线"
                });

                items.Add(new TimeLineItem()
                {
                    Timestamp="2024-07-26",
                    PlacementType= TimeLinePlacementTypeEnum.Top,
                    Content=App.CreateTag("测试控件", TagType.Success)
                });

            }).AddToChildren(child);
        }),

        App.CreatePartContainer("卡片控件", child =>
        {
            

            App.CreateSpace(children =>
            {

                App.CreateCard(500, "字符串标题", content =>
                {
                    App.CreateTip("内容", TipType.Success, children2 =>
                    {
                        App.CreateText("测试文本内容").AddToChildren(children2);

                    }).AddToChildren(content);


                },"字符串底部").AddToChildren(children);


                App.CreateCard(500,titleFunc: () =>App.CreateText("文本控件标题"), content =>
                {
                    App.CreateTip("内容", TipType.Success, children2 =>
                    {
                        App.CreateText("测试文本内容").AddToChildren(children2);

                    }).AddToChildren(content);

                },footerFunc:()=>App.CreateText("文本控件底部内容") ).AddToChildren(children);


            }).AddToChildren(child);

            

        }),

        App.CreatePartContainer("走马灯", child =>
        {
            App.CreateCarousel(120, items =>
            {
                items.Add(App.CreateCarouselItem(120, () =>
                {
                    //return App.CreateText("11111", TextType.Success);
                    return App.CreateImage(false,"https://fuss10.elemecdn.com/a/3f/3302e58f9a181d2509f3dc0fa68b0jpeg.jpeg");
                }));

                items.Add(App.CreateCarouselItem(120, () =>
                {
                    //return App.CreateText("22222", TextType.Primary);
                    return App.CreateImage(true,"/assets/Vampirewal-Logo.png");
                }));

            }).AddToChildren(child);

        }),

        App.CreatePartContainer("Tabs标签页展示", child =>
        {
            App.CreatePartContainer("1.1、测试下级Part", part =>
            {

            },3).AddToChildren(child);


            App.CreateTabs(panes =>
            {
                panes.Add(App.CreateTabPane("标签1", () =>
                {
                    return App.CreateTip("标签1中的Tip", TipType.Tip, tipChild =>
                    {
                        App.CreateTag("测试提示", TagType.Info).AddToChildren(tipChild);
                    });

                }));

                panes.Add(App.CreateTabPane("标签2", () =>
                {
                    return App.CreateTip("标签2中的Warning", TipType.Warning, tipChild =>
                    {
                        App.CreateTag("测试提示2", TagType.Info).AddToChildren(tipChild);
                    });

                }));

            }).AddToChildren(child);


        }),

    };
}

[FormModel(hasButton: true)]
[FormButton("提交", ButtonType.Success, ButtonExcuteType.Submit, "TestFormClick")]
[FormButton("关闭当前页", ButtonType.Danger, ButtonExcuteType.Custom, "TestFormClick")]
public class TestFormModel
{
    /// <summary>
    /// 姓名
    /// </summary>
    [FormInput("姓名", "请输入姓名")]
    public string Name { get; set; }

    [FormNumInput("年龄", 18, 50, 0, 1)]
    public int Age { get; set; }
}

[Table]
public class TestTable
{
    [TableItem("姓名")]
    public string Name { get; set; }

    [TableItem("年龄")]
    public int Age { get; set; }

    [TableItem("地址")]
    public string Address { get; set; }
}